//
//  HomeViewController.m
//  YMDemo
//
//  Created by admin on 2022/3/14.
//
#import "HomeViewController.h"
#import <Masonry/Masonry.h>
#import "UIButton+TQEasyIcon.h"
#import "UIButton+Gradient.h"
#import "GetPushParaViewController.h"
#import "GetPlayViewController.h"
@interface HomeViewController ()

@property (nonatomic,strong)UIButton *setButton;
@property (nonatomic,strong)UIImageView *logonImageView;
@property (nonatomic,strong)UILabel *logoLable;
@property (nonatomic,strong)UIButton *pushButton;
@property (nonatomic,strong)UIButton *playButton;

@end

@implementation HomeViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.title = @"直播Live";
    self.view.backgroundColor = [UIColor whiteColor];
    [self initView];
   
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
-(void)initView{
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:self.setButton];
    self.navigationItem.rightBarButtonItem = item;

    
    [self.view addSubview:self.logonImageView];
    [self.logonImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(self.view.mas_top).offset(130);
        make.size.mas_equalTo(CGSizeMake(90, 90));

    }];
    
    [self.view addSubview:self.logoLable];
    [self.logoLable mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(self.logonImageView.mas_bottom).offset(20);


    }];
    [self.view addSubview:self.pushButton];
    [self.pushButton mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(self.view.mas_top).offset([UIScreen mainScreen].bounds.size.height/2);
        make.size.mas_equalTo(CGSizeMake([UIScreen mainScreen].bounds.size.width-115, 45));

    }];
    [self.pushButton gradientButtonWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width-115, 45) colorArray:@[(id)[UIColor colorWithRed:84/255.0 green:177/255.0 blue:246/255.0 alpha:1],(id)[UIColor colorWithRed:58/255.0 green:127/255.0 blue:248/255.0 alpha:1]] percentageArray:@[@(0.18),@(1)] gradientType:GradientFromLeftToRight];
    [self.pushButton setIconInRightWithSpacing:5];
   

    [self.view addSubview:self.playButton];
    [self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(self.pushButton.mas_bottom).offset(40);
        make.size.mas_equalTo(CGSizeMake([UIScreen mainScreen].bounds.size.width-115, 45));
        
    }];
    [self.playButton gradientButtonWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width-115, 45) colorArray:@[(id)[UIColor colorWithRed:84/255.0 green:177/255.0 blue:246/255.0 alpha:1],(id)[UIColor colorWithRed:58/255.0 green:127/255.0 blue:248/255.0 alpha:1]] percentageArray:@[@(0.18),@(1)] gradientType:GradientFromLeftToRight];
    [self.playButton setIconInRightWithSpacing:5];
    
}
#pragma mark 设置
-(void)setAction{
    
    
}
#pragma mark 推流
-(void)pushAction{
    
    GetPushParaViewController *vc = [[GetPushParaViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
}
#pragma mark 播放
-(void)playAction{
    
    GetPlayViewController *vc = [[GetPlayViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
    
}
//-(void)viewWillAppear:(BOOL)animated{
//
//    [super viewWillAppear:animated];
//    self.navigationController.navigationBar.hidden = YES;
//    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
//}
//-(void)viewWillDisappear:(BOOL)animated{
//
//    [super viewWillDisappear:animated];
//    self.navigationController.navigationBar.hidden = NO;
//    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
//}
-(UIImageView *)logonImageView{
    
    if (_logonImageView == nil) {
        
        _logonImageView = [[UIImageView alloc]init];
        _logonImageView.backgroundColor = [UIColor orangeColor];
        _logonImageView.layer.cornerRadius = 45;
        _logonImageView.clipsToBounds = YES;
        [_logonImageView setImage:[UIImage imageNamed:@"Avatar"]];
        
    }
    
    return _logonImageView;
}
-(UILabel *)logoLable{
    
    if (_logoLable==nil) {
        _logoLable = [[UILabel alloc]init];
        _logoLable.text = @"YMLive";
        _logoLable.textColor = [UIColor blackColor];
        _logoLable.textAlignment = NSTextAlignmentCenter;
        _logoLable.font = [UIFont systemFontOfSize:21];
    }
    
    return _logoLable;
}
-(UIButton *)setButton{
    
    if (_setButton == nil) {
        
        _setButton = [[UIButton alloc]init];
        [_setButton setImage:[UIImage imageNamed:@"Image_Setting"] forState:UIControlStateNormal];
        [_setButton addTarget:self action:@selector(setAction) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    return _setButton;
}
-(UIButton *)pushButton{
    
    if (_pushButton == nil) {
        
        _pushButton = [[UIButton alloc]init];
        [_pushButton addTarget:self action:@selector(pushAction) forControlEvents:UIControlEventTouchUpInside];
        [_pushButton setTitle:@"推流" forState:UIControlStateNormal];
        _pushButton.titleLabel.font = [UIFont systemFontOfSize:21];
        [_pushButton setImage:[UIImage imageNamed:@"Live_Arrow"] forState:UIControlStateNormal];
        [_pushButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _pushButton.layer.cornerRadius = 22;
        _pushButton.clipsToBounds = YES;
    }
    
    return _pushButton;
}
-(UIButton *)playButton{
    
    if (_playButton == nil) {
        
        _playButton = [[UIButton alloc]init];
        _playButton.backgroundColor = [UIColor colorWithRed:51/255.0 green:133/255.0 blue:255/255.0 alpha:1];
        [_playButton addTarget:self action:@selector(playAction) forControlEvents:UIControlEventTouchUpInside];
        [_playButton setTitle:@"播放" forState:UIControlStateNormal];
        _playButton.titleLabel.font = [UIFont systemFontOfSize:21];
        [_playButton setImage:[UIImage imageNamed:@"Live_Arrow"] forState:UIControlStateNormal];
        [_playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _playButton.layer.cornerRadius = 22;
        _playButton.clipsToBounds = YES;
        
    }
    
    return _playButton;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
